package cn.com.yang.thread;

import java.io.File;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * 
 * @author 杨亿金
 * @date 2022年8月13日-下午10:48:09
 * @since 1.0.0
 */
public class GzipAllFiles {
	public static final int  THREAD_COUNT=4;
	
	public static void main(String[] args) {
		ExecutorService  pool = Executors.newFixedThreadPool(THREAD_COUNT);
		for (String fileName:args) {
			File f = new File(fileName);
			if (f.exists()) {
				if (f.isDirectory()) {
					File[] files = f.listFiles();
					for (int i = 0; i < files.length; i++) {
						if (!files[i].isDirectory()) {
							Runnable task = new GzipRunnable(files[i]);
							pool.submit(task);
						}
					}
				}else {
					Runnable task = new GzipRunnable(f);
					pool.submit(task);
				}
			}
		}
		pool.shutdown();
	}
}
